package threading;

/**
 * 通过重写Thread实现线程接口
 */
 class Threading extends Thread {
    @Override
    public void run() {
        while (true) {
            System.out.println("hello threading");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
public class Demo1 {
    public static void main(String[] args) {
        //把线程要干的话和线程分开了
        MyRunnable myRunnable = new MyRunnable();
        Thread threading = new Thread(myRunnable);
        threading.start();
        while (true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }


}

